/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package twitter.api;

/**
 *
 * @author Puma
 */
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import twitter4j.Paging;
import twitter4j.ResponseList;
import twitter4j.Status;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.User;
import twitter4j.auth.AccessToken;

public class Twitter {
    private List<Status> statusess;
    
    public void Twitter(String User) {
        twitter4j.Twitter twitter = new TwitterFactory().getInstance();
        twitter.setOAuthConsumer("VytaNnUyaOvphlAbl9x7RQxVJ", "5jjoUjpbTJDfEB3U1CuUT2Yr3Hzzz7uxI0nC4fEjk7b2XP1sT7");
        twitter.setOAuthAccessToken(new AccessToken("88084133-tSC95sXcjplL26HB2BXiHk8TKs9NgFCp45B6IqmhC", "O8G39r55CxEtNK6FwbiDC01dlUOb0o8oHzWkmioOQwDjv"));

        try {
            String[] srch = new String[]{User};
            ResponseList<User> users = twitter.lookupUsers(srch);
            //ResponseList<Status> a = twitter.getUserTimeline(new Paging(1,5));
            //List<Status> st = twitter.getUserTimeline();
            //ResponseList<Status> st = twitter.getUserTimeline();
            //long id = twitter.getId();
//        	for(Status b: st) {
//        		System.out.println(b.getText() + ", id=" + id);
//        	}
            for (User user : users) {
                System.out.println("Friend's Name " + user.getName()); // this print my friends name
                if (user.getStatus() != null) {
                    System.out.println("Friend timeline");
                     
                    try {
                        statusess = twitter.getUserTimeline("AprovechaCCS");
                    } catch (TwitterException ex) {
                        Logger.getLogger(Twitter.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    int count = 1;
                    for (Status status3 : statusess) {
                        System.out.println(status3.getText());
                        System.out.println(count++);
                    }
                }
            }
        } catch (Exception e) {
            System.out.println(e);

        }
    }
}
